{extend name="layout" /} {block name="main"}
<div class="wrapper wrapper-content animated fadeInRight">
	<div class="row">
		<div class="col-sm-10">
			<div class="ibox float-e-margins" style="height: 900px;">
				<div class="ibox-title">
					<h5></h5>
					<div class="ibox-tools">
						<a class="collapse-link">
							<i class="fa fa-chevron-up"></i>
						</a>
					</div>
				</div>
				<div class="ibox-content">
					<section>
						<!-- page heading start-->
						<div class="page-heading">
							<h3>广告列表</h3>
						</div>
						<!-- page heading end-->
						<!--body wrapper start-->
						<div class="wrapper">
							<div class="row">
								<div class="col-sm-12">
									<section class="panel">
										<header class="panel-heading">
											<div class="pull-right">
												<select class="input-sm m-bot15" name="position" onchange="search(this)">
													<option value="0">所有广告</option>
													{volist name='position' id='v'}
													<option value="{$v.id}" {if $info[ 'id'] eq $v[ 'id']}selected{/if}>{$v.name}</option>
													{/volist}
												</select>

												<a class="btn btn-success btn-sm" href="#myModal_position" data-toggle="modal" id="addposition"><i class="fa fa-plus"></i>&nbsp添加位置</a>
												<a class="btn btn-success btn-sm" href="{:url('add_ad')}"><i class="fa fa-plus"></i>&nbsp添加广告</a>
												<a id="show" href="#myModal" data-toggle="modal" style="display:none;"></a>

											</div>
										</header>
										<div class="panel-body">
											<section id="unseen">
												<table class="table table-striped table-bordered table-hover " id="editable">
							                        <thead>
							                            <tr>
							                                <th>ID</th>
															<th>图片</th>
															<th>名称</th>
															<th>排序</th>
															<th>新窗口</th>
															<th>状态</th>
															<th>操作</th>
							                            </tr>
							                        </thead>
							                        <tbody>
							                        	{volist name='data' id='v'}
							                            <tr class="gradeX">
							                                <td>{$v.id}</td>
							                                <td><img src="{$v.img}" height="60"></td>
							                                <td>{$v.name}</td>
							                                <td><input type="text" name="sort" id="sort" value="{$v.sort}" size=4 onblur="sort(this,{$v.id})"></td>
							                                <td>
							                                	{if $v.new eq 1}
																<a class="btn btn-success btn-xs" onclick="status(this,{$v.id},{$v.new},'new')">是</a>
																{else/}
																<a class="btn btn-danger btn-xs" onclick="status(this,{$v.id},{$v.new},'new')">否</a>
																{/if}</td>
							                                <td>
							                                	<div>
									                            {if $v['status'] eq 1}
									                              <span class="yes" ><i class="fa fa-check-circle"></i>正常</span>
									                            {else /}
									                              <span class="no" ><i class="fa fa-ban"></i>隐藏</span>
									                            {/if}
									                          	</div>
							                                </td>
							                                <td class="center">
							                                	<a href="{:url('edit_category',['id'=>$v.id])}" class="btn btn-outline btn-primary btn-xs dim" title="修改">		<i class="fa fa-pencil fa-fw"></i>
											                    </a>
											                    <a data-url="{:url('delete', ['id' => $v['id'], 'table' => 'article_category'])}" class="btn btn-outline btn-danger btn-xs dim confirm" title="删除">
											                    	<i class="fa fa-times fa-fw"></i>
											                    </a>
							                                </td>
							                            </tr>
							                            {/volist}
							                        </tbody>
							                    </table>

												<div class="col-md-12 text-center clearfix">
													<ul class="pagination">
														{$page}
													</ul>
												</div>

											</section>
										</div>
									</section>

								</div>

							</div>
						</div>
						<!--body wrapper end-->
					</section>
					
					<div class="modal" id="modal" style="display: none;background:rgba(0,0,0,0.5);">
						<div class="modal-dialog">
							<div class="modal-content" style="margin-top: 200px;z-index: 9999999;position: fixed;width: 400px;">
								<div class="modal-header">
									<button aria-hidden="true" data-dismiss="modal" class="close" id="close" type="button">×</button>
									<h4 class="modal-title">添加位置</h4>
								</div>
								<div class="modal-body">
									<form action="#" id="article_cate" method="post" class="form-horizontal adminex-form">
										<div class="form-group">
											<div class="col-md-12">
												<label class="col-sm-1 control-label col-md-4" for="pname">位置名称</label>
												<div class="col-md-7">
													<input name="pname" id="pname" class="form-control m-bot15" type="text" placeholder="导航名称">
												</div>
											</div>
										</div>
										<div class="form-group ">
											<label class="col-sm-3 control-label col-md-3" for="submit"></label>
											<div class="col-md-6">
												<input name="pid" id="pid" value="0" type="hidden">
												<input name="type" id="type" value="1" type="hidden">
												<a id="delete" onclick="del(0)" class="btn btn-danger btn-sm" type="button">关闭</a>
												<a id="save" onclick="position()" class="btn btn-success btn-sm">保存</a>
											</div>
										</div>
									</form>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>

<script type="text/javascript">
	/**
	 * AJAX提交表单
	 * @author 陈一中
	 * @return {[type]} [description]
	 */
	function save() {
		var radio = $("#radio").val();
		$.ajax({
			url: "/admin/Basic/update_basic.html",
			type: 'post',
			dataType: 'json',
			data: {
				name: name
			},
			success: function(res) {
				if(res.status == true) {
					layer.msg(res.info);
					setTimeout(function() {
						window.location.href = "/Basic/index.html";
					}, 1000);
				} else {
					layer.msg(res.info);
				}
			},
			error: function() {
				layer.alert('服务器繁忙，稍后再试', {
					icon: 5
				});
			}
		})
	}

	/**
	 * 添加位置JS代码
	 * @param  
	 * @author 陈一中
	 */
	$("#addposition").click(function() {
		$("#modal").css("display", "block");
	});
	$("#close").click(function() {
		$("#modal").css("display", "none");
	})
</script>
{/block}